define([],function(){
	return{
		aa:(function(){  //轮播图
			var $oLi=$('#banner .slide li');
			var $oI=$('#banner .sbtn i');
			var $index=0;  //图片索引
			var timer=null;
			var bstop=true;
			/*$oI.on('mouseover',function(){
				$(this).addClass('cur').siblings('i').removeClass('cur');
//				$oLi.eq($(this).index()).css('opacity','1').siblings('li').css('opacity','0');
				$oLi.eq($(this).index()).animate({opacity:1},500).siblings().animate({opacity:0},500);
			});*/
			$oI.on('mouseover',function(){
				$(this).addClass('cur').addClass('ac').siblings('i').removeClass('cur').removeClass('ac');
				$oLi.eq($(this).index()).animate({opacity:1},800).siblings().animate({opacity:0},800);
				var $i=$(this).index();  //获取哪个按钮被点击，就是哪个按钮的索引值
				$index=$i;
			});
			timer=setInterval(function(){
				if($oI.attr('class')=='ac'){
					clearInterval(timer);
				}else{
					$index++;
					if($index>$oI.length-1){  //当到达最后一张图时，让索引赋值给第一张图的索引
						$index=0;
					}
					$oI.eq($index).trigger('mouseover');
				}
			},4000);
			
		})(),
		bb:(function(){  //数据导入
			var $img=$('#recommend .lay-t img');
			var $tit=$('#recommend .lay-b .tit');
			var $new=$('#recommend .lay-b .new em');
			var $old=$('#recommend .lay-b .old em');
			var $group=$('#recommend .group');
			$.ajax({
				url:'php/mysql.php',
				dataType:'json'
			}).done(function(data){
				for(var i=0;i<$img.length;i++){
					$img[i].src=data[i].url;
					$tit[i].innerHTML=data[i].title;
					$new[i].innerHTML=data[i].price;
					$old[i].innerHTML=data[i].oldprice;
				}
			});
			
			$group.on('mouseenter',function(){  //鼠标进过改变透明度
				$(this).animate({opacity:.8},50);
//				$group.eq($(this).index()).animate({opacity:.8},50);
			});
			$group.on('mouseleave',function(){
				$(this).animate({opacity:1},50);
			})
		})(),
		cc:(function(){  //今日特卖
			var $layout=$('#spe .layout');
//		 	var layout=document.getElementById('spe').getElementsByClassName('layout')[0];
		 	var box='';
		 	for(var i=0;i<20;i++){
		 		box+='<div class="block">'
		 			+'<a href="javascript:;" class="bigpic">'
						+'<img class="lazyload" src="https://img04.miyabaobei.com/d1/p5/2017/09/04/62/d9/62d95c7bfb7a502364adbb50e20579ea176795754.jpg" data-src="https://img04.miyabaobei.com/d1/p5/2017/09/04/62/d9/62d95c7bfb7a502364adbb50e20579ea176795754.jpg" width="750" height="350" alt="阿迪达斯限时特惠">'
					+'</a>'
					+'<div class="rank">';
						for(var j=0;j<3;j++){
							box+='<a href="javascript:;">'
							+'<div class="l">'
								+'<img class="lazyload" src="https://img04.miyabaobei.com/d1/p5/item/0/0/17421110445158_2.jpg" data-src="https://img04.miyabaobei.com/d1/p5/item/0/0/17421110445158_2.jpg" />'
								+'<i class="r1"></i>'
							+'</div>'
							+'<div class="r">'
								+'<p class="tit">'+'暇步士 Hush Puppies 2017年春秋新款幼儿真皮皮鞋男女童学生鞋1-3岁DP9047'+'</p>'
								+'<div class="price">'
									+'<span class="new">'+'￥'+'<em>'+'159.00'+'</em></span>'
									+'<span class="old">'+'￥'+'<em>'+'447.50'+'</em></span>'
								+'</div>'
							+'</div>'
						+'</a>';
						}
					box+='</div>';	
		 		box+='</div>';
		 	}
		 	$layout.html(box);
		})(),
		dd:(function(){  //大牌尖货
			var $bags=$('#big .bags');
//			var bags=document.getElementById('big').getElementsByClassName('bags')[0];
		 	var box='';
		 	for(var i=0;i<10;i++){
		 		box+='<div class="layout"><div class="title">'
					+'<div class="tit1">'
						+'<a href="javascript:;">'
							+'<span class="img"><img src="https://img03.miyabaobei.com/d1/p3/brand/94_brand_logo_img1464342140.jpg" /></span>'
							+'尤妮佳 moony'+'</a></div>'
					+'<a href="javascript:;" class="tit2">正在参加拼团活动></a>'
				+'</div>'
				+'<div class="block">';
					for(var j=0;j<5;j++){
						box+='<div class="items">'
							+'<a href="javascript:;">'
								+'<div class="aimg">'
									+'<img class="lazyload" src="https://img05.miyabaobei.com/d1/p5/item/10/1047/1047865_topic_1.jpg@base@tag=imgScale&amp;w=447" data-src="https://img05.miyabaobei.com/d1/p5/item/10/1047/1047865_topic_1.jpg@base@tag=imgScale&amp;w=447">'
									+'<span class="free">'+'立减'+'</span>'
								+'</div>'
								+'<div class="adesc">'
									+'<p class="tit">'+'全球购 自营 | 纸尿裤L54片*4包 （9-14kg）'+'</p>'
									+'<div class="price">'
										+'<span class="new">'+'￥'+'<em>'+'309'+'</em></span>'
										+'<span class="old">'+'￥'+'<em>'+'752'+'</em></span>'
									+'</div>'
								+'</div>'
							+'</a>'
						+'</div>';
					}
				box+='</div></div>';
		 	}
		 	$bags.html(box);
		 	
		 	$.ajax({
				url:'php/mysql.php',
				dataType:'json'
			}).done(function(data){
				var $img=$('#big .items img');
				var $tit=$('#big .adesc .tit');
				var $new=$('#big .adesc .new em');
				var $old=$('#big .adesc .old em');
				for(var i=0;i<$img.length;i++){
					$img[i].src=data[i].url;
					$tit[i].innerHTML=data[i].title;
					$new[i].innerHTML=data[i].price;
					$old[i].innerHTML=data[i].oldprice;
				}
			});
		})(),
		ee:(function(){
			//楼梯的显示与隐藏
			$(window).on('scroll',function(){
				var scrolltop=$(this).scrollTop();
				if(scrolltop>=800){
					$('#louti').show();
				}else{
					$('#louti').hide();
				}
			});
			//左侧楼梯的菜单，和菜单对应的内容模块跳转到对应的位置
			$('#louti li').not('.top').on('click',function(){
				var $index=$(this).index();
				var $scroll=$('.loutis').eq($index).offset().top;  //每个内容块对应的offsetTop
				$('html,body').animate({
					scrollTop:$scroll-100
				});
			});
			//回到顶部按钮
    		$('.top').on('click',function(){
    			$('html,body').animate({
    				scrollTop:0
    			});
    		});
		})()
	}
})
